##############################################################
#Figure 5: Common Trends U.S. Senate and House
##############################################################

trends.data.sen <-read.dta13("./temp/fig5adata.dta")
trends.data.house <-read.dta13("./temp/fig5bdata.dta")
trends.data.sen$evertr <- as.factor(trends.data.sen$evertr)
trends.data.house$evertr <- as.factor(trends.data.house$evertr)

g1 <- ggplot(trends.data.sen, aes(as.factor(post), senate, group=as.factor(evertr))) + 
  geom_line(aes(color=evertr), lwd=1, linetype="solid")  +
  scale_color_manual(values=c("black", "goldenrod1"),labels=c("Control", "Treatment"), name="Treatment Status") + 
  ylab("Democrat Vote Share Senate") + xlab("Time") + 
  scale_x_discrete(breaks=c("1", "2", "3", "4", "5"), labels = c("-2", "-1", "0", "1", "2")) +
  scale_y_continuous(breaks=c(.35,.45, .55, .65), limits = c(.35,.65)) +
  theme(axis.text=element_text(size=12), 
        axis.title = element_text(size=15))
g1


g2 <- ggplot(trends.data.house, aes(as.factor(post), house, group=as.factor(evertr))) + geom_line(aes(color=evertr), lwd=1, linetype="solid") + 
  scale_color_manual(values=c("black", "goldenrod1"), labels=c("Control", "Treatment"), name="Treatment Status") + 
  ylab("Democrat Vote Share House") + xlab("Time") + 
  scale_x_discrete(breaks=c("1", "2", "3", "4", "5"), labels = c("-2", "-1", "0", "1", "2"))  + 
  scale_y_continuous(breaks=c(.35,.45,.55,.65), limits = c(.35,.65)) +
  theme(axis.text=element_text(size=12), 
        axis.title = element_text(size=15))
g2

ggarrange(g1,g2,ncol = 2, common.legend = T)
ggsave(file="./figures/fig5.pdf")


